package refactortips.editors.refactorings;

import org.eclipse.swt.SWT;
import org.eclipse.swt.browser.Browser;
import org.eclipse.swt.custom.ScrolledComposite;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.TabFolder;
import org.eclipse.swt.widgets.TabItem;
import org.eclipse.ui.forms.widgets.Form;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.wb.swt.ResourceManager;
import org.eclipse.wb.swt.SWTResourceManager;

import refactortips.editors.AbstractRefactorTipsEditor;

public class RenameMethodEditor extends AbstractRefactorTipsEditor {

	private final FormToolkit formToolkit = new FormToolkit(Display.getDefault());

	public RenameMethodEditor() {
	}

	/**
	 * Create contents of the editor part.
	 * @param parent
	 */
	@Override
	public void createPartControl(Composite parent) {
		
		Form frmRefactoring = formToolkit.createForm(parent);
		formToolkit.paintBordersFor(frmRefactoring);
		frmRefactoring.setText("Rename Method");
		frmRefactoring.getBody().setLayout(new FillLayout(SWT.HORIZONTAL));
		
		TabFolder tabFolder = new TabFolder(frmRefactoring.getBody(), SWT.NONE);
		formToolkit.adapt(tabFolder);
		formToolkit.paintBordersFor(tabFolder);
		
		ScrolledComposite sc = new ScrolledComposite(tabFolder, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
		sc.setExpandHorizontal(true);
	    sc.setExpandVertical(true);
		
		TabItem tbtmDescription = new TabItem(tabFolder, SWT.NONE);
		tbtmDescription.setText("Descri\u00E7\u00E3o");
		
		ScrolledComposite scrolledComposite = new ScrolledComposite(tabFolder, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
		tbtmDescription.setControl(scrolledComposite);
		formToolkit.paintBordersFor(scrolledComposite);
		scrolledComposite.setExpandHorizontal(true);
		scrolledComposite.setExpandVertical(true);
		
		Composite composite_3 = new Composite(scrolledComposite, SWT.NONE);
		formToolkit.adapt(composite_3);
		formToolkit.paintBordersFor(composite_3);
		composite_3.setLayout(null);
		
		Label lblShortcutValue = new Label(composite_3, SWT.NONE);
		lblShortcutValue.setBounds(344, 553, 106, 39);
		lblShortcutValue.setText("Alt + Shift + R");
		lblShortcutValue.setFont(SWTResourceManager.getFont("Segoe UI", 12, SWT.BOLD));
		lblShortcutValue.setAlignment(SWT.CENTER);
		formToolkit.adapt(lblShortcutValue, true, true);
		
		Label lblShortcutText = new Label(composite_3, SWT.NONE);
		lblShortcutText.setBounds(94, 553, 234, 21);
		lblShortcutText.setText("Selecione um m\u00E9todo e pressione");
		lblShortcutText.setFont(SWTResourceManager.getFont("Segoe UI", 12, SWT.NORMAL));
		lblShortcutText.setAlignment(SWT.CENTER);
		formToolkit.adapt(lblShortcutText, true, true);
		
		Label lblShortcut = new Label(composite_3, SWT.NONE);
		lblShortcut.setBounds(10, 550, 78, 42);
		lblShortcut.setText("Atalho");
		lblShortcut.setFont(SWTResourceManager.getFont("Segoe UI", 14, SWT.BOLD));
		formToolkit.adapt(lblShortcut, true, true);
		
		Label lblDiagram = new Label(composite_3, SWT.NONE);
		lblDiagram.setBounds(177, 126, 461, 118);
		lblDiagram.setImage(ResourceManager.getPluginImage("RefactorTips", "images/refactor/rename/rename.png"));
		formToolkit.adapt(lblDiagram, true, true);
		
		Label lblDescriptionValue = new Label(composite_3, SWT.NONE);
		lblDescriptionValue.setBounds(156, 65, 496, 42);
		lblDescriptionValue.setFont(SWTResourceManager.getFont("Segoe UI", 12, SWT.NORMAL));
		lblDescriptionValue.setAlignment(SWT.CENTER);
		formToolkit.adapt(lblDescriptionValue, true, true);
		lblDescriptionValue.setText("O nome do m\u00E9todo n\u00E3o revela o seu prop\u00F3sito.\r\nAltere o seu nome.");
		
		Label lblMotivation = new Label(composite_3, SWT.NONE);
		lblMotivation.setBounds(10, 254, 98, 25);
		lblMotivation.setFont(SWTResourceManager.getFont("Segoe UI", 14, SWT.BOLD));
		formToolkit.adapt(lblMotivation, true, true);
		lblMotivation.setText("Motiva\u00E7\u00E3o");
		
		Label lblDescription = new Label(composite_3, SWT.NONE);
		lblDescription.setBounds(10, 10, 102, 25);
		lblDescription.setForeground(SWTResourceManager.getColor(SWT.COLOR_BLACK));
		lblDescription.setFont(SWTResourceManager.getFont("Segoe UI", 14, SWT.BOLD));
		formToolkit.adapt(lblDescription, true, true);
		lblDescription.setText("Descri\u00E7\u00E3o");
		
		StyledText styledText = new StyledText(composite_3, SWT.READ_ONLY | SWT.WRAP);
		styledText.setText("\t\tA vida como ela \u00E9, voc\u00EA n\u00E3o ir\u00E1 nomear corretamente na primeira vez. Nessa situa\u00E7\u00E3o voc\u00EA poder\u00E1 ser tentado para deixar do jeito que est\u00E1 \u2013 afinal \u00E9 apenas um nome. Isso \u00E9 obra do maligno \u201CObfuscatis\u201D; n\u00E3o d\u00EA ouvidos a ele. Se voc\u00EA ver um m\u00E9todo, vari\u00E1vel ou classe com um nome ruim, \u00E9 imperativo que voc\u00EA mude. Lembre-se que o seu c\u00F3digo \u00E9 em primeiro lugar para um humano e em segundo para um computador. Humanos precisam de bons nomes. Observe quando voc\u00EA gasta muito tempo tentando fazer algo que seria mais f\u00E1cil se alguns m\u00E9todos tivessem sidos nomeados melhor. Nomear bem \u00E9 uma habilidade que requer pr\u00E1tica; Aperfei\u00E7oar essa habilidade \u00E9 a chave para ser um verdadeiro programador habilidoso.");
		styledText.setFont(SWTResourceManager.getFont("Segoe UI", 12, SWT.NORMAL));
		styledText.setDoubleClickEnabled(false);
		styledText.setJustify(true);
		styledText.setEnabled(false);
		styledText.setBounds(92, 328, 712, 169);
		formToolkit.adapt(styledText);
		formToolkit.paintBordersFor(styledText);
		scrolledComposite.setContent(composite_3);
		scrolledComposite.setMinSize(composite_3.computeSize(SWT.DEFAULT, SWT.DEFAULT));
		
		TabItem tbtmUsage = new TabItem(tabFolder, SWT.NONE);
		tbtmUsage.setText("Exemplo");
		
		ScrolledComposite scrolledComposite_1 = new ScrolledComposite(tabFolder, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
		tbtmUsage.setControl(scrolledComposite_1);
		formToolkit.paintBordersFor(scrolledComposite_1);
		scrolledComposite_1.setExpandHorizontal(true);
		scrolledComposite_1.setExpandVertical(true);
		
		Composite composite = new Composite(scrolledComposite_1, SWT.NONE);
		formToolkit.adapt(composite);
		formToolkit.paintBordersFor(composite);
		
		Label lblNewLabel_4 = new Label(composite, SWT.NONE);
		lblNewLabel_4.setLocation(43, 111);
		lblNewLabel_4.setSize(405, 280);
		lblNewLabel_4.setImage(ResourceManager.getPluginImage("RefactorTips", "images/refactor/rename/renameSample1.1.png"));
		formToolkit.adapt(lblNewLabel_4, true, true);
		
		Label label_1 = new Label(composite, SWT.NONE);
		label_1.setImage(ResourceManager.getPluginImage("RefactorTips", "images/refactor/rename/renameSample1.2.png"));
		label_1.setBounds(563, 122, 312, 269);
		formToolkit.adapt(label_1, true, true);
		
		Label lblNewLabel_2 = new Label(composite, SWT.NONE);
		lblNewLabel_2.setImage(ResourceManager.getPluginImage("RefactorTips", "images/rightPointer.png"));
		lblNewLabel_2.setBounds(468, 227, 66, 36);
		formToolkit.adapt(lblNewLabel_2, true, true);
		scrolledComposite_1.setContent(composite);
		scrolledComposite_1.setMinSize(composite.computeSize(SWT.DEFAULT, SWT.DEFAULT));
		
		TabItem tbtmVideo = new TabItem(tabFolder, SWT.NONE);
		tbtmVideo.setText("Video");
		
		Browser browser = new Browser(tabFolder, SWT.NONE);
		browser.setUrl("www.youtube.com/embed/luxTTftgUjo");
		tbtmVideo.setControl(browser);
		formToolkit.paintBordersFor(browser);
	}
}
